

#ifndef __COMM_MSG_GNSS_POSE_H__
#define __COMM_MSG_GNSS_POSE_H__

#include "comm/comm_topic_name.h"
#include "comm/comm_base.h"
#include "comm/comm_msg.h"
#include <comm_msg/gnssPose.h>
#include <ros/ros.h>
#include <iostream>
#include <list>
#include <vector>

using namespace std;

/**************************************************************************************
功能描述: 发布消息
修改记录:
**************************************************************************************/

/**************************************************************************************
功能描述: 接收消息
修改记录:
**************************************************************************************/
class GNSS_POSE_RECEIVER_C
{
public:
    GNSS_POSE_RECEIVER_C(ros::NodeHandle &nh, double overTime = 0.15)
    {
        subscriber_ = nh.subscribe(TOPIC_NAME_LOC_GNSS_POSE, 1, &GNSS_POSE_RECEIVER_C::ReceiveMsgCallBack, this);

        objInvalidTimer_.SetOverTime(overTime);
        stGpsPose_.SetZero();
    }

    INT32 Get(GPS_POSE_STRU &stGpsPose) const
    {
        if (objInvalidTimer_.IsTimeOut()) {
            return -1;
        }
        
        stGpsPose = stGpsPose_;
        return 0;
    }
    
private:
    ros::Subscriber subscriber_;

    TIMER_C         objInvalidTimer_;
    GPS_POSE_STRU   stGpsPose_;

    void ReceiveMsgCallBack(const comm_msg::gnssPose::ConstPtr &pstMsg)
    {
        R_ASSERT(pstMsg != NULL, NOTHING);

        objInvalidTimer_.Reset();

        stGpsPose_.stCoord.lon = pstMsg->longitude;
        stGpsPose_.stCoord.lat = pstMsg->latitude;
        stGpsPose_.stCoord.alt = pstMsg->altitude;
        stGpsPose_.yawAngle    = pstMsg->yawAngle;
    }
};

#endif

